package com.zcn.io.web.controller;

import com.zcn.io.common.pojo.CommonResult;
import com.zcn.io.web.api.query.AnswerStatisticQuery;
import com.zcn.io.web.api.entity.AnswerRecord;
import com.zcn.io.web.api.vo.AnswerRecordVo;
import com.zcn.io.web.service.AnswerRecordService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @desc:
 * @author: 202438 邱建伟
 * @date: 2024/10/4 15:25
 * @Copyright (c) 2024, 江苏金恒信息科技股份有限公司
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/answerRecord")
public class AnswerRecordController {

    private final AnswerRecordService answerRecordService;

    @GetMapping("/getDetailByOrderId")
    public CommonResult<AnswerRecordVo> getDetailByOrderId(AnswerStatisticQuery query) {
        return CommonResult.success(answerRecordService.getDetailByOrderId(query));
    }

    @PostMapping("/updateAll")
    public CommonResult<String> updateAll(@RequestBody List<AnswerRecord> answerRecords) {
        answerRecordService.updateAll(answerRecords);
        return CommonResult.success("更新成功!");
    }

    @DeleteMapping("/deleteById")
    public CommonResult<String> deleteById(String id) {
        answerRecordService.deleteById(id);
        return CommonResult.success("删除成功!");
    }
}
